import Vue from 'vue'
import Router from 'vue-router'

const _import = require('./_import_' + process.env.NODE_ENV)
// const _import = require('./_import_' + process.env.NODE_ENV)

Vue.use(Router)

// 固定的路由
const staticRouterMap = [
  { path: '/login', component: _import('login/Login'), hidden: true },
  // { path: '/authredirect', component: _import('login/authredirect'), hidden: true },
  // { path: '/404', component: _import('errorPage/404'), hidden: true },
  // { path: '/401', component: _import('errorPage/401'), hidden: true },
  {
    path: '/',
    name: 'Layout',
    component: _import('layout/Layout'),
    children: [
      {
        path: '/',
        component: _import('Sf')
      }
    ]
  }, {
    path: '/content',
    redirect: '/content/index',
    component: _import('layout/Layout'),
    children: [
      {
        path: 'index',
        component: _import('cms/Content')
      },
      {
        path: 'edit',
        component: _import('cms/ContentEdit')
      }, {
        path: 'table',
        component: _import('Table')
      }
    ]
  }, {
    path: '/devices',
    redirect: '/devices/list',
    component: _import('layout/Layout'),
    children: [
      {
        path: 'list',
        component: _import('devices/list')
      }
    ]
  }
]
export default new Router({
  // 填充新的页面时自动定位到顶部
  scrollBehavior: () => ({ y: 0 }),
  routes: staticRouterMap
})
